package com.yjd.bi.user.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.yjd.bi.user.dto.UserBaseInfoDto;
import com.yjd.bi.user.dto.UserRemainDto;
import com.yjd.bi.user.dto.UserTicketUsedDto;
import com.yjd.bi.user.model.UserStatisticInfoModel;
import org.springframework.stereotype.Service;

import com.yjd.bi.user.dao.IUserDao;
import com.yjd.bi.user.dto.UserRankDto;
import com.yjd.bi.user.model.UserModel;
import com.yjd.bi.user.service.IUserService;
import com.yjd.comm.base.dao.IBaseDao;
import com.yjd.comm.base.service.impl.BaseServiceImpl;

/**
 * <b>description</b>：微信分享红包业务实现<br>
 * <b>time</b>：2016-12-14 16:43:52 <br>
 * <b>author</b>：  ready likun_557@163.com
 */
@Service("userService")
public class UserServiceImpl extends BaseServiceImpl implements IUserService {

	/**
	 * 插入
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public UserModel insert(UserModel model) throws Exception {
		return this.userDao.insertModel(model, true);
	}

	/**
	 * 更新
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public int update(UserModel model) throws Exception {
		return this.userDao.updateModel(model, true);
	}

	/**
	 * 根据id删除
	 * 
	 * @param user_id
	 * @return
	 * @throws Exception
	 */
	public int delete(long user_id) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("user_id", user_id);
		return this.userDao.deleteModel(paramMap, true);
	}

	@Resource
	private IUserDao userDao;

	@Override
	public IBaseDao getBaseDao() {
		return this.userDao;
	}

	@Override
	public List<UserRankDto> getRankUsers(int type, Map<String, Object> paramMap)
			throws Exception {
		// TODO Auto-generated method stub
		return userDao.getRankUsers(type,paramMap);
	}

	@Override
	public List<UserStatisticInfoModel> queryChannelUserStatics(Map<String, Object> paramMap) throws Exception {
		return userDao.queryChannelUserStatics(paramMap);
	}

	@Override
	public UserBaseInfoDto queryUserInfoById(Long user_id) throws Exception {
		return userDao.queryUserInfoById(user_id);
	}

	@Override
	public UserRemainDto queryUserRemainInfoById(Long user_id) throws Exception {
		return userDao.queryUserRemainInfoById(user_id);
	}

	@Override
	public UserTicketUsedDto queryUserTicketsUsedRecentlyById(Long user_id) throws Exception {
		return userDao.queryUserTicketsUsedRecentlyById(user_id);
	}
}
